using UnityEngine;

public class MarketProductInfo : MonoBehaviour
{
	public MarketGunInfoPanel gunInfoPanel;

	public MarketCarInfoPanel carInfoPanel;

	public MarketCarUpgradesInfoPanel carUpsInfoPanel;

	public MarketComsumableInfoPanel comsumableInfoPanel;

	public MarketArmorInfoPanel armorInfoPanel;

	public MarketWearableInfoPanel wearableInfoPanel;

	public MarketSkinInfoPanel skinInfoPanel;

	public MarketComsumableTextInfoPanel comsumableTextInfoPanel;

	public MarketTitanMiniInfoPanel titanInfoPanel;

	private Product _product;

	private bool _needComparison = true;

	public Product Product
	{
		get
		{
			if (_product != null)
			{
				return _product;
			}
			return MarketControllerUI.instance.selectedProduct;
		}
		set
		{
			_product = value;
			_needComparison = false;
		}
	}

	public void ShowInfoPanel()
	{
		HideInfoPanels();
		if (Product == null)
		{
			return;
		}
		switch (Product.GetType().ToString())
		{
		case "ProductWeapon":
			gunInfoPanel.gameObject.SetActive(true);
			gunInfoPanel.SetInfo(Product, true, _needComparison);
			break;
		case "ProductComsumable":
			comsumableInfoPanel.gameObject.SetActive(true);
			comsumableInfoPanel.SetInfo(Product, true, _needComparison);
			break;
		case "ProductArmor":
			armorInfoPanel.gameObject.SetActive(true);
			armorInfoPanel.SetInfo(Product, true, _needComparison);
			break;
		case "ProductBoot":
			wearableInfoPanel.gameObject.SetActive(true);
			wearableInfoPanel.SetInfo(Product, true, _needComparison);
			break;
		case "ProductHat":
			wearableInfoPanel.gameObject.SetActive(true);
			wearableInfoPanel.SetInfo(Product, true, _needComparison);
			break;
		case "ProductSkin":
			skinInfoPanel.gameObject.SetActive(true);
			skinInfoPanel.SetInfo(Product, true, _needComparison);
			break;
		case "ProductCar":
		case "ProductTank":
		case "ProductTitan":
			if (!MarketControllerUI.instance.marketHolder.activeInHierarchy)
			{
				carInfoPanel.gameObject.SetActive(true);
				carInfoPanel.SetInfo(Product, true, _needComparison);
			}
			else if (!Product.Purchased || !MarketController.Instance.HaveCarUpgrades(Product.id))
			{
				carInfoPanel.gameObject.SetActive(true);
				carInfoPanel.SetInfo(Product, true, _needComparison);
			}
			else if ((bool)carUpsInfoPanel)
			{
				carUpsInfoPanel.gameObject.SetActive(true);
				carUpsInfoPanel.SetInfo(Product, true, _needComparison);
			}
			break;
		case "ProductBoost":
			if ((bool)comsumableTextInfoPanel)
			{
				comsumableTextInfoPanel.gameObject.SetActive(true);
				comsumableTextInfoPanel.SetInfo(Product, true, _needComparison);
			}
			break;
		}
	}

	public void UpdateInfoPanel()
	{
		if (gunInfoPanel.gameObject.activeSelf)
		{
			gunInfoPanel.SetInfo(Product, false);
		}
		if (armorInfoPanel.gameObject.activeSelf)
		{
			ShowInfoPanel();
		}
		if (Product is ProductCar && IsActive())
		{
			ShowInfoPanel();
		}
	}

	public bool IsActive()
	{
		return gunInfoPanel.gameObject.activeSelf || carInfoPanel.gameObject.activeSelf || comsumableInfoPanel.gameObject.activeSelf || armorInfoPanel.gameObject.activeSelf || (wearableInfoPanel != null && wearableInfoPanel.gameObject.activeSelf) || (skinInfoPanel != null && skinInfoPanel.gameObject.activeSelf) || (comsumableTextInfoPanel != null && comsumableTextInfoPanel.gameObject.activeSelf) || (carUpsInfoPanel != null && carUpsInfoPanel.gameObject.activeSelf);
	}

	public void HideInfoPanels()
	{
		gunInfoPanel.CloseInfoPanel();
		carInfoPanel.CloseInfoPanel();
		comsumableInfoPanel.CloseInfoPanel();
		armorInfoPanel.CloseInfoPanel();
		if ((bool)carUpsInfoPanel)
		{
			carUpsInfoPanel.CloseInfoPanel();
		}
		if ((bool)wearableInfoPanel)
		{
			wearableInfoPanel.CloseInfoPanel();
		}
		if ((bool)skinInfoPanel)
		{
			skinInfoPanel.CloseInfoPanel();
		}
		if ((bool)comsumableTextInfoPanel)
		{
			comsumableTextInfoPanel.CloseInfoPanel();
		}
	}

	public void HideInfoPanelButton()
	{
		HideInfoPanels();
		MarketControllerUI.instance.productsPanel.productMiniInfoPanel.ShowMiniInfoPanel();
	}
}
